#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import sys
import time


# time.sleep(1)
# print("\r[{:<{}}]".format("#", 40), end="")
# time.sleep(1)
# print("\r[{:<40}]".format("##"), end="")
# time.sleep(1)
# print("\r[{:<40}]".format("###"), end="")
# time.sleep(1)
# print("\r[{:<40}]".format("####"), end="")

def process(precent, width=50):
    precent = 1 if precent >= 1 else precent
    show_str = "[{:<{}}]".format(int(precent * width) * "#", width)
    print("\r{} {}%".format(show_str, int(precent * 100)), end="")


count_filesize = 20480
filesize = 0
while filesize < count_filesize:
    filesize += 1024
    precent = round(filesize / count_filesize, 2)
    time.sleep(0.1)
    process(precent)
